package ldzy.soft1;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import java.io.PrintWriter;

public class ServletRoute1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("hello");
//        读取web.xml中，为本servlet配置的参数
//        第一步：通过this对象的getServletConfig方法获取servletConfig对象
        ServletConfig servletConfig=this.getServletConfig();
//        第二步：使用ServletConfig对象的getInitParameter方法来返回对应参数值
        String schoolName=servletConfig.getInitParameter("schoolName");
//        封装成一个响应消息
//        第一步：在response参数中提取一个PrintWrite对象
        PrintWriter out= response.getWriter();
//        第二步：用PrintWrite对象的write方法，往浏览器输出内容
        out.write(schoolName);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
